import request from '@/utils/request'

export function getOrgs(params) {
    return request({
        url: `/online/authorization/organization/list-children`,
        method: 'GET',
        params
    })
}


export function getCurrentOrgs(params) {
  return request({
    url: `/online/authorization/organization`,
    method: 'GET',
    params
  })
}

export function getRootOrg() {
    return request({
        url: `/online/authorization/organization/self`,
        method: 'GET'
    })
}

export function getSlefTopOrg() {
  return request({
    url: `/online/authorization/organization/self/top`,
    method: 'GET'
  })
}

export function getOrgInfo(orgId) {
    return request({
        url: `/online/management/operator/org/${orgId}/details`,
        method: 'GET'
    })
}

export function addOrg(data) {
    return request({
        url: `/online/management/operator/org`,
        method: 'POST',
        data
    })
}

export function editOrg(orgId, data) {
  return request({
      url: `/online/management/operator/org/${orgId}`,
      method: 'POST',
      data
  })
}

export function getOrg(orgId) {
  return request({
      url: `/online/authorization/organization/${orgId}`,
      method: 'GET'
  })
}

export function countDevByModel(params) {
  return request({
    url: '/online/management/operator/device/count-by-model',
    method: 'get',
    params
  })
}
export function countDevByStatus(params) {
  return request({
    url: '/online/management/operator/device/count-by-status',
    method: 'get',
    params
  })
}
export function countOnlineDevByDay(params) {
  return request({
    url: '/online/management/operator/device/count-online-by-day',
    method: 'get',
    params
  })
}
export function getDeviceList(params) {
  return request({
    url: '/online/management/estate/device/list',
    method: 'get',
    params
  })
}

export function getDeviceListByMrchId(params) {
  return request({
    url: `/online/management/operator/merchant/${params.mrchId}/device-list`,
    method: 'get',
    params
  })
}

export function getDeviceListBySnOrTid(params) {
  return request({
    url: '/online/management/estate/device/complex/list',
    method: 'get',
    params
  })
}

export function verifyAddDevice(params) {
  return request({
    url: `/online/management/estate/mrch/${params.mrchId}/device/${params.devSn}/verify`,
    method: 'POST'
  })
}
export function getBelonging(params) {
  return request({
    url: '/online/management/operator/device/get-org-belonging',
    method: 'GET',
    params
  })
}

export function deleteOrg(orgId) {
  return request({
    url: `/online/management/operator/org/${orgId}`,
    method: 'delete'
  })
}

export function merchServiceOpen() {
  return request({
    url: `/online/management/operator/merchant-service/open`,
    method: 'GET'
  })
}
